<?php $this->load->view("admin/$adminCurrentTemplate/commonHead2");?>
<table width="99%" border="0" cellspacing="1" cellpadding="0" class="editFormContainer">
    <form id="editForm" name="editForm" method="post" action="<?=$this->input->server('REQUEST_URI')?>">
	<input type="hidden" name="id" id="id" value="<?=$id?>" />
    <tr>
      <td class="guid">启用状态：</td>
      <td class="formItem">
	  	<input type="radio" name="disabled" id="disabled-0" value="0" checked/><label for="disabled-0"<?php if($disabled==0) echo ' checked'?>>启用</label>
		<input type="radio" name="disabled" id="disabled-1" value="1"<?php if($disabled==1) echo ' checked'?> /><label for="disabled-1">禁用</label>
	  </td>
    </tr>
    <tr>
      <td class="guid">排序索引：</td>
      <td class="formItem"><input type="text" name="oIndex" id="oIndex" class="sing-line" value="<?=$oIndex?>" /></td>
    </tr>
    <tr>
      <td class="guid">变量标题：</td>
      <td class="formItem"><input type="text" name="title" id="title" class="sing-line input-title" value="<?=$title?>" /></td>
    </tr>
    <tr>
      <td class="guid">变量名称：</td>
      <td class="formItem"><input type="text" name="name" id="name" class="sing-line input-name" value="<?=$name?>" /></td>
    </tr>
    <tr>
      <td class="guid">变量取值：</td>
      <td class="formItem"><textarea name="value" id="value" class="multi-line"><?=$value?></textarea></td>
    </tr>
   <tr>
      <td class="guid">备注说明：</td>
      <td class="formItem"><?php echo $this->miniCKEditor->editor("remark", $remark);?></td>
    </tr>
</form>
</table>
<?php $this->load->view("admin/$adminCurrentTemplate/commonFoot2");?>

<script type="text/javascript">
var tvName = '<?php if(isset($tvName)) echo $tvName;?>';
$(function(){
	$('#name').bind('blur',nameBlur);
	var id = $('#id').val();
	dg.addBtn('subBtn','提 交',subForm);
	if(id.length==0) dg.SetTitle('添加系统配置项');
})

var nameBlur = function(){
	var id = $.trim($('#id').val());
	var name = $.trim($('#name').val());
	$.ajax({
		type:'POST',
		url:getInfo + '/check/',
		data:'tvName=' + tvName + '&fieldName=name&fieldValue=' + name + '&id=' + id,
		success:function(returnValue){
			if(parseInt(returnValue)>0){
				subMess(208,108,'变量名称错误','<span class="red">对不起，变量名称已经存在！</span>',$("#name"));
				return false;
			}
		}
	});
}

var subForm = function(){
	var id = $.trim($('#id').val());
	var disabled = $.trim($('#disabled').val());
	var oIndex = $.trim($('#oIndex').val());
	var title = $.trim($('#title').val());
	var name = $.trim($('#name').val());
	var value = $.trim($('#value').val());
	var values = $.trim($('#values').val());
	if(!isNumber(oIndex)){
		subMess(208,108,'排序索引错误','<span class="red">对不起，排序索引不合法！</span>',$("#oIndex"));
		return false;
	}
	if(title.length==0){
		subMess(208,108,'变量标题错误','<span class="red">对不起，请输入变量标题！</span>',$("#title"));
		return false;
	}
	if(name.length==0){
		subMess(208,108,'变量名称错误','<span class="red">对不起，请输入变量名称！</span>',$("#name"));
		return false;
	}
	if(value.length==0){
		subMess(200,108,'变量值错误','<span class="red">对不起，请输入变量值！</span>',$("#value"));
		return false;
	}
	
	//return false;
	$('#editForm').submit();
}
</script>